package com.java3_8;

//饿汉单例模式
public class Demo3 {
    private String name;
    private int age;

    //私有化构造器
    private Demo3(String name, int age) {
        this.name = name;
        this.age = age;
    }

    //创建对象
    private static Demo3 demo3 = new Demo3("lisi",20);

    //使用方法使对象展现
    public static Demo3 getDemo3(){
        return demo3;
    }

    @Override
    public String toString() {
        return "Demo3{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
